# -*- coding: utf8 -*-
# $Id :  $



# Copyright 2008-2010, Pascal Fautrero & JCharles
#
# This file is part of PyArchiver.
# 
# PyArchiver is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyArchiver is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyArchiver.  If not, see <http://www.gnu.org/licenses/>.



# Requires wxPython.  This sample demonstrates :
# - single file exe using wxPython as GUI.


# Import packages

from distutils.core import setup
import py2exe
import sys
import shutil

# Remove the build folder
shutil.rmtree("build", ignore_errors=True)

# Do the same for dist folder
shutil.rmtree("dist", ignore_errors=True)

#---------------------------------------------------------------------------

# If run without args, build executables, in quiet mode.
if len(sys.argv) == 1:
    sys.argv.append("py2exe")
    sys.argv.append("-q")

#---------------------------------------------------------------------------
    
class Target:
    def __init__(self, **kw):
        self.__dict__.update(kw)
        
############################################################################
#  A program using wxPython
#
#  The manifest will be inserted as resource into test_wx.exe.  This
#  gives the controls the Windows XP/Seven appearance (if run on XP/Seven ;-)
#
#  Another option would be to store it in a file named
#  test_wx.exe.manifest, and copy it with the data_files option into
#  the dist-dir.
############################################################################

MANIFEST_TEMPLATE = """
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    version="5.0.0.0"
    processorArchitecture="x86"
    name="%(prog)s"
    type="win32"
  />
  <description>%(prog)s</description>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
            level="asInvoker"
            uiAccess="false">
        </requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
            type="win32"
            name="Microsoft.VC90.CRT"
            version="9.0.21022.8"
            processorArchitecture="x86"
            publicKeyToken="1fc8b3b9a1e18e3b">
      </assemblyIdentity>
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="X86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
  </dependency>
</assembly>
"""

#---------------------------------------------------------------------------

RT_MANIFEST = 24

PyArchiver = Target(
    # Used for the versioninfo resource
    description = u"GUI wxPython pour archivage CD/DVD...",

    # What to build
    script = u"PyArchiver.py",
    icon_resources = [(1, u"icon_app.ico")],
    other_resources = [(RT_MANIFEST, 1, MANIFEST_TEMPLATE % dict(prog=u"PyArchiver"))], 
    dest_base = u"PyArchiver",
    version = "2.7.0",
    company_name = u"Pascal & JCie",
    copyright = u"Copyright © 2008 - 2010",
    name = u"PyArchiver"
    )

############################################################################
#  COM pulls in a lot of stuff which we don't want or need.
############################################################################

setup(
    options = {"py2exe" : {"compressed" : 1, # Compress the library archive (1)
                           "optimize" : 2, # (2)
                           "ascii": False, # To make a smaller executable, don't include the encodings
                           "bundle_files" : 2, # (1) Create singlefile exe
                           #"includes" : INCLUDES,
                           "excludes" : ["_gtkagg", "_tkagg", "bsddb", "curses", "email",
                                         "pywin.debugger", "pywin.debugger.dbgcon",
                                         "pywin.dialogs", "tcl", "Tkconstants", "Tkinter"],
                           #"packages": packages,
                           "dll_excludes": ["tcl84.dll", "tk84.dll", "MSVCP90.dll"] }},

    data_files = ["msvcr90.dll", "gdiplus.dll"],
    zipfile = None,  # Append zip-archive to the executable.
    windows = [PyArchiver],
    )


